package com.piece.core.web.authority;

import com.piece.core.framework.support.dto.UserDetailDTO;
import javax.servlet.http.HttpServletRequest;
import java.util.Collection;

public interface AuthorityService {

    /**
     * 获取Token
     */
    String extractToken(HttpServletRequest request);

    /**
     * 解析clientId
     */
    String extractClientId(HttpServletRequest request);

    /**
     * 解析clientId:clientSecret
     */
    String[] extractClient(HttpServletRequest request);

    /**
     * 获取登录用户权限
     */
    Collection getUserAuthorities();

    /**
     * 判断登录用户是否有某个权限
     */
    boolean isPermitted(String... permission);

    /**
     * 判断用户是否在线
     */
    String checkUserOnlineState(String clientId, String loginName);

    /**
     * 强制用户下线
     */
    boolean offLineUser(String clientId, String loginName);

    /**
     * 用户自动登录
     * @return token
     */
    String autoLogin(String clientId, UserDetailDTO userDetail);
}
